package com.sys.SysWaterQuality.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sys.common.utils.DateUtils;
import com.sys.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sys.common.annotation.Log;
import com.sys.common.core.controller.BaseController;
import com.sys.common.core.domain.AjaxResult;
import com.sys.common.enums.BusinessType;
import com.sys.SysWaterQuality.domain.SysWaterQualityInspection;
import com.sys.SysWaterQuality.service.ISysWaterQualityInspectionService;
import com.sys.common.utils.poi.ExcelUtil;
import com.sys.common.core.page.TableDataInfo;

/**
 * 水质巡查记录Controller
 * 
 * @author ruoyi
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/SysWaterQuality/SysWaterQualityInspection")
public class SysWaterQualityInspectionController extends BaseController
{
    @Autowired
    private ISysWaterQualityInspectionService sysWaterQualityInspectionService;

    /**
     * 查询水质巡查记录列表
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQualityInspection:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWaterQualityInspection sysWaterQualityInspection)
    {
        startPage();
        List<SysWaterQualityInspection> list = sysWaterQualityInspectionService.selectSysWaterQualityInspectionList(sysWaterQualityInspection);
        return getDataTable(list);
    }

    /**
     * 导出水质巡查记录列表
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQualityInspection:export')")
    @Log(title = "水质巡查记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWaterQualityInspection sysWaterQualityInspection)
    {
        List<SysWaterQualityInspection> list = sysWaterQualityInspectionService.selectSysWaterQualityInspectionList(sysWaterQualityInspection);
        ExcelUtil<SysWaterQualityInspection> util = new ExcelUtil<SysWaterQualityInspection>(SysWaterQualityInspection.class);
        util.exportExcel(response, list, "水质巡查记录数据");
    }

    /**
     * 获取水质巡查记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQualityInspection:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysWaterQualityInspectionService.selectSysWaterQualityInspectionById(id));
    }

    /**
     * 新增水质巡查记录
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQualityInspection:add')")
    @Log(title = "水质巡查记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWaterQualityInspection sysWaterQualityInspection)
    {
        sysWaterQualityInspection.setCreateBy(SecurityUtils.getUsername());
        sysWaterQualityInspection.setUpdateBy(SecurityUtils.getUsername());
        sysWaterQualityInspection.setCreateTime(DateUtils.getNowDate());
        sysWaterQualityInspection.setUpdateTime(DateUtils.getNowDate());
        return toAjax(sysWaterQualityInspectionService.insertSysWaterQualityInspection(sysWaterQualityInspection));
    }

    /**
     * 修改水质巡查记录
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQualityInspection:edit')")
    @Log(title = "水质巡查记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWaterQualityInspection sysWaterQualityInspection)
    {
        sysWaterQualityInspection.setUpdateBy(SecurityUtils.getUsername());
        sysWaterQualityInspection.setUpdateTime(DateUtils.getNowDate());
        return toAjax(sysWaterQualityInspectionService.updateSysWaterQualityInspection(sysWaterQualityInspection));
    }

    /**
     * 删除水质巡查记录
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQualityInspection:remove')")
    @Log(title = "水质巡查记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysWaterQualityInspectionService.deleteSysWaterQualityInspectionByIds(ids));
    }
}
